import Vue from 'vue'
import VueRouter from 'vue-router'
// import { nextTick } from '_vue@2.6.14@vue/types/umd'
import recommend from '../views/recommend.vue'

Vue.use(VueRouter)

const routes = [
  {
    path:"/",
    redirect:"/recommend"
  },
  //首页
  {
    path:"/recommend",
    name:"recommend",
    component:recommend
  },
  //歌手
  {
    path:"/singer",
    name:"singer",
    component:()=>import("../views/singer.vue")
  },
  //歌手歌曲列表
  {
    path:"/singer/singerlist",
    name:"singerlist",
    component:()=>import("../components/singer/singerlist.vue")
  },
  //排行榜
  {
    path:"/rank",
    name:"rank",
    component:()=>import("../views/rank.vue")
  },
  //歌单歌曲列表
  {
    path:"/rank/ranklist",
    name:"ranklist",
    component:()=>import("../components/rank/ranklist.vue")
  },
  //我的
  {
    path:"/userInfo",
    name:"userInfo",
    component:()=>import("../views/userinfo.vue"),
    beforeEnter:(to,from,next)=>{
      let login = window.localStorage.getItem("token");
      // 判断没有值
      if(!login){
        next("/login");
        return;
      }else{
        next();
      }
    }
  },
  //登录
  {
    path:"/login",
    name:"login",
    component:()=>import("../components/base/login.vue")
  },
  //搜索
  {
    path:"/search",
    name:"search",
    component:()=>import("../views/search.vue")
  },
  //发现
  {
    path:"/discover",
    name:"discover",
    component:()=>import("../views/discover.vue")
  },
  //歌单
  {
    path:"/playcont",
    name:"playcont",
    component:()=>import("../components/base/playcont.vue")
  },
  //MV
  {
    path:"/mv",
    name:"mv",
    component:()=>import("../components/base/mv.vue")
  },
  //电台
  {
    path:"/radioStation",
    name:"radioStation",
    component:()=>import("../components/base/radioStation.vue")
  },
  //mv播放
  {
    path:"/mvplay",
    name:"mvplay",
    component:()=>import("../components/base/mvplay.vue")
  },
  //收藏
  {
    path:"/collection",
    name:"collection",
    component:()=>import("../components/base/collection.vue")
  },
  //评论
  {
    path:"/muise",
    name:"muise",
    component:()=>import("../components/base/muise.vue")
  },
  //关注
  {
    path:"/follo",
    name:"follo",
    component:()=>import("../views/follo.vue")
  },
  //热门电台
  {
    path:"/hotaudio",
    name:"hotaudio",
    component:()=>import("../components/base/hotaudio.vue")
  },
  
]

const router = new VueRouter({
  // mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
